/*
* Author: zhfayuan Create at 2021/8/31.
* Email:afst2012@outlook.com
* Copyright：
* Desc：
* Version:
* History：
*/


#ifndef GB28181KIT_AUDIORESAMPLER_H
#define GB28181KIT_AUDIORESAMPLER_H

#include <memory>
#include <vector>
#include <functional>

#include <speex/speex_resampler.h>

class AudioResampler
{
public:
    AudioResampler();
    virtual  ~AudioResampler();
private:
    uint32_t  _out_rate;
    uint32_t  _out_channel;
    uint32_t  _in_channel;
    bool _initialize;
    SpeexResamplerState *_st;
    uint8_t _in_pcm[4096 * 2];
    uint8_t _out_pcm[4096 * 8];
public:
    void initialize(int32_t in_rate,int32_t out_rate,int32_t channel);
    void resample(std::shared_ptr<std::vector<char>> &in,std::function<void(std::shared_ptr<std::vector<char>>&out,int32_t rate,int32_t channel)> func);
};


#endif //GB28181KIT_AUDIORESAMPLER_H
